home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue31 / webcomm / TRNQF.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-01-14  |  2.7 KB  |  104 lines

  1. unit TrnQf;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, webtrans,
  7.   StdCtrls, Buttons, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Panel1: TPanel;
  12.     Button1: TButton;
  13.     Button2: TButton;
  14.     BitBtn1: TBitBtn;
  15.     Edit2: TEdit;
  16.     Edit3: TEdit;
  17.     Edit4: TEdit;
  18.     Edit5: TEdit;
  19.     Label2: TLabel;
  20.     Label3: TLabel;
  21.     Label4: TLabel;
  22.     Label5: TLabel;
  23.     SimpleFileTransactionQueuer1: TSimpleFileTransactionQueuer;
  24.     Status: TPanel;
  25.     ICVerifyTransactionQueuer1: TICVerifyTransactionQueuer;
  26.     Panel2: TPanel;
  27.     Label1: TLabel;
  28.     Edit1: TEdit;
  29.     UseICVerify: TCheckBox;
  30.     procedure FormCreate(Sender: TObject);
  31.     procedure Edit1Change(Sender: TObject);
  32.     procedure Button1Click(Sender: TObject);
  33.     procedure BitBtn1Click(Sender: TObject);
  34.     procedure UseICVerifyClick(Sender: TObject);
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   Form1: TForm1;
  43.   Queuer: TCustomFileTransactionQueuer; // so we can switch queuing methods at run time
  44.  
  45. implementation
  46.  
  47. {$R *.DFM}
  48.  
  49. procedure TForm1.FormCreate(Sender: TObject);
  50. begin
  51.    Edit1.text := ExtractFilePath(paramstr(0));
  52.    Queuer := SimpleFileTransactionQueuer1;
  53. end;
  54.  
  55. procedure TForm1.Edit1Change(Sender: TObject);
  56. begin
  57.   SimpleFileTransactionQueuer1.QueueDirectory := Edit1.text;
  58.   ICVerifyTransactionQueuer1.QueueDirectory := Edit1.text;
  59. end;
  60.  
  61. procedure TForm1.Button1Click(Sender: TObject);
  62. begin // same logic for Queue AND Check...
  63.   with Queuer,Queuer.TransactionData do
  64.   begin
  65.     TransactionID := Edit5.Text; { name }
  66.     Comment := 'Sample transaction';
  67.     CardNumber:= Edit2.Text;
  68.     ExpiryMonth:=Edit3.Text; { 01..12 }
  69.     ExpiryYear:=Edit4.Text;  { 98, 99, 2000, 2001... }
  70.     TransactionAmount :='20';
  71.     QueueTransaction;
  72.     Status.Caption := StatusMessage+' at '+DateTimeToStr(Age);
  73.     if TransactionStatus in ([tsTimeOut, tsInvalid, tsCancel, tsAccept, tsReject]) then
  74.        DeleteTransaction
  75.     else { I guess it's queued }
  76.       if not UseICVerify.checked then
  77.         showmessage('Have a look in "'+Edit5.text+
  78.           '.trn" for the details ');
  79.   end;
  80.  
  81. end;
  82.  
  83. procedure TForm1.BitBtn1Click(Sender: TObject);
  84. begin
  85.   with Queuer,Queuer.TransactionData do
  86.   begin
  87.     TransactionID := Edit5.Text; { name }
  88.     CancelTransaction;
  89.     Status.Caption := StatusMessage;
  90.     if TransactionStatus in ([tsTimeOut, tsInvalid, tsCancel, tsAccept, tsReject]) then
  91.       DeleteTransaction; // harmless if already done
  92.   end;
  93. end;
  94.  
  95. procedure TForm1.UseICVerifyClick(Sender: TObject);
  96. begin
  97.   if UseICVerify.checked then
  98.      Queuer := ICVerifyTransactionQueuer1
  99.   else
  100.      Queuer := SimpleFileTransactionQueuer1
  101. end;
  102.  
  103. end.
  104.